package com.artPreter.controller;


import com.artPreter.pojo.SystemConfig;
import com.artPreter.pojo.Result;
import com.artPreter.service.ISystemConfigService;
import com.artPreter.service.ISystemConfigService;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 系统设置表 前端控制器
 * </p>
 *
 * @author jarvis
 * @since 2024-12-27
 */
@RestController
@RequestMapping("/systemConfig")
public class SystemConfigController {



    @Autowired
    private ISystemConfigService systemConfigService;

    /**
     * 系统设置分页
     * @param currentPage
     * @param size
     * @param
     * @return
     */
    @PostMapping("/getPage")
    public Result getPage(@RequestParam(value = "currentPage",defaultValue = "1") Integer currentPage, @RequestParam(value = "size",defaultValue = "10") Integer size, @RequestBody SystemConfig systemConfig) {
        IPage<SystemConfig> systemConfigIPage = systemConfigService.getPage(currentPage, size, systemConfig);
        return Result.success(systemConfigIPage);
    }

    /**
     *  添加系统设置
     * @param systemConfig
     * @return
     */
    @PostMapping("/add")
    public Result add(@RequestBody SystemConfig systemConfig) {
        systemConfigService.add(systemConfig);
        return Result.success();
    }

    /**
     *  修改系统设置
     * @param
     * @return
     */
    @PostMapping("/edit")
    public Result edit(@RequestBody SystemConfig systemConfig) {
        systemConfigService.edit(systemConfig);
        return Result.success();
    }

    /**
     * 删除系统设置
     * @param
     * @return
     */
    @PostMapping("/delete")
    public Result delete(@RequestBody SystemConfig systemConfig){
        systemConfigService.delete(systemConfig);
        return Result.success();
    }

    /**
     * 获取系统设置列表
     * @param
     * @return
     */
    @PostMapping("/getList")
    public Result getList(@RequestBody SystemConfig systemConfig){
        List<SystemConfig> result = systemConfigService.getList(systemConfig);
        return Result.success(result);
    }

    /**
     * 批量保存设置
     * @param
     * @return
     */
    @PostMapping("/saveList")
    public Result saveList(@RequestBody List<SystemConfig> systemConfigList){
        systemConfigService.saveBatchData(systemConfigList);
        return Result.success();
    }

}
